var e = require("../../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  n = require("../../../config/index"),
  a = require("../../../utils/index"),
  r = require("./utils");
Page({
  useStore: function (e) {
    return {}
  },
  data: {
    list: [],
    loading: !1,
    noData: !1,
    hasMore: !1,
    tabList: [{
      title: "待打卡",
      mode: t.seeking,
      "filter-key": "seekingParams"
    }, {
      title: "审核拒绝",
      mode: t.hire,
      "filter-key": "hireParams"
    }],
    mode: "",
    tabActive: 0,
    currentTabDesc: null,
    id: ""
  },
  onTabChange: function (o) {
    var i = this;
    return t(e().mark((function t() {
      var s;
      return e().wrap((function (e) {
        switch (e.prev = e.next) {
          case 0:
            if (o.detail) {
              e.next = 2;
              break
            }
            return e.abrupt("return");
          case 2:
            s = n.tabList[o.detail.index].mode, i.setData({
              currentTabDesc: r.tabDescList[s],
              tabActive: o.detail.index,
              mode: s
            }, (function () {
              a.operateDom.moveToTop().then((function () {
                r.onRefresh.call(i, 1)
              }))
            }));
          case 4:
          case "end":
            return e.stop()
        }
      }), t)
    })))()
  },
  onLoad: function (options) {
    console.log(t.seeking)
    this.setData({
      id: options.id
    })
    var a = this;
    return t(e().mark((function t() {
      var o;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            o = n.tabList[a.data.tabActive].mode, a.setData({
              mode: o,
              currentTabDesc: r.tabDescList[o]
            }, (function () {
              a.setData({
                load:true
              })
              r.onRefresh.call(a, 1).finally(()=>{
                a.setData({
                  load:false
                })
              })
            }));
          case 2:
          case "end":
            return e.stop()
        }
      }), t)
    })))()
  },
  onShow: function () {
    var a = this;
    a.setData({
      load:true
    })
    r.onRefresh.call(a, 1).finally(()=>{
      a.setData({
        load:false
      })
    })
  },
  getList(){
    var a = this;
    a.setData({
      load:true
    })
    r.onRefresh.call(a, 1).finally(()=>{
      a.setData({
        load:false
      })
    })
  },
  onPullDownRefresh: function () {
    r.onRefresh.call(this, 1).finally((function () {
      wx.stopPullDownRefresh()
    }))
  },
  onReachBottom: function () {
    this.data.hasMore || this.data.noData || r.onRefresh.call(this, this.page + 1)
  },
  onToPublish: function () {
    var e = r.tabDescList[this.data.mode].url;
    e && $.router.push(e)
  },
  onMachineTap: function (e) {
    var t = this.data.mode,
      n = e.currentTarget.dataset.item;
    n.uu_id && $.router.push("/subpackage/common/details/index", {
      uuid: n.uu_id,
      mode: t
    })
  },
  logDetail(e){
    wx.navigateTo({
      url: '/subpackage/clock-in/detail/index?id='+e.currentTarget.dataset.id,
    })
  },
  getDetail(e) {
    console.log(e)
    // $.request['GET/business/engineering/log/detail/' + e.currentTarget.dataset.id]()
  },
  endClock(e) {
    console.log(e)
    wx.navigateTo({
      url: '/subpackage/clock-in/end/index?engineeringId=' + e.currentTarget.dataset.info.engineeringId + '&id=' + e.currentTarget.dataset.info.id,
    })
  },
  onOperateClick: function (n) {
    var o = this,
      i = this.data.mode,
      s = n.currentTarget.dataset,
      u = s.cardInfo,
      c = s.btnInfo;
    (0, r.handleButtonEvent)(u, c, i, t(e().mark((function t() {
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            a.operateDom.moveToTop().then((function () {
              r.onRefresh.call(o, 1)
            }));
          case 1:
          case "end":
            return e.stop()
        }
      }), t)
    }))))
  },
  onShareGroup: function () {
    this.setData({
      showInvite: !0
    })
  },
  onCloseInvite: function () {
    this.setData({
      showInvite: !1
    })
  },
  onOperateClick() {
    wx.navigateTo({
      url: '/subpackage/clock-in/end/index',
    })
  },
  onClickRelease: function () {
    wx.navigateTo({
      url: '/subpackage/clock-in/add/index',
    })
  }
});